<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="bolao" />
    <g:set var="entityName" value="${message(code: 'user.label', default: 'User')}" />
    <title><g:message code="default.create.label" args="[entityName]" /></title>
  </head>
  <body>
    <div class="body">
      <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
      </g:if>
      <g:hasErrors bean="${user}">
      <div class="errors">
        <g:renderErrors bean="${user}" as="list" />
      </div>
      </g:hasErrors>
      <g:form action="save">
        <div class="dialog">
        <fieldset>
          <legend><g:message code="default.create.label" args="[entityName]" /></legend>
          <table>
          <tbody>
            <tr class="prop">
              <td valign="top" class="name"><label for="username"><g:message code="user.username.label" default="Username"/>:</label></td>
              <td valign="top" class="value ${hasErrors(bean:user,field:'username','errors')}">
                <input type="text" id="username" name="username" value="${user.username?.encodeAsHTML()}"/>
              </td>
            </tr>
            <tr class="prop">
              <td valign="top" class="name"><label for="firstname"><g:message code="user.firstname.label" default="Firstname"/>:</label></td>
              <td valign="top" class="value ${hasErrors(bean:user,field:'firstname','errors')}">
                <input type="text" id="firstname" name="firstname" value="${user.firstname?.encodeAsHTML()}"/>
              </td>
            </tr>
            <tr class="prop">
              <td valign="top" class="name"><label for="surname"><g:message code="user.surname.label" default="Surname"/>:</label></td>
              <td valign="top" class="value ${hasErrors(bean:user,field:'surname','errors')}">
                <input type="text" id="surname" name="surname" value="${user.surname?.encodeAsHTML()}"/>
              </td>
            </tr>
            <tr class="prop">
              <td valign="top" class="name"><label for="password"><g:message code="user.password.label" default="Password"/>:</label></td>
              <td valign="top" class="value ${hasErrors(bean:user,field:'password','errors')}">
                <input type="password" id="password" name="password" value="${user.password?.encodeAsHTML()}"/>
              </td>
            </tr>
            <tr class="prop">
              <td valign="top" class="name"><label for="contactNumber"><g:message code="user.contactNumber.label" default="Contact Number"/>:</label></td>
              <td valign="top" class="value ${hasErrors(bean:user,field:'contactNumber','errors')}">
                <input type="text" id="contactNumber" name="contactNumber" value="${user.contactNumber?.encodeAsHTML()}"/>
              </td>
            </tr>
            <tr class="prop">
              <td valign="top" class="name"><label for="email"><g:message code="user.email.label" default="Email"/>:</label></td>
              <td valign="top" class="value ${hasErrors(bean:user,field:'email','errors')}">
                <input type="text" id="email" name="email" value="${user.email?.encodeAsHTML()}"/>
              </td>
            </tr>
            <tr class="prop">
              <td valign="top" class="name" align="left"><g:message code="user.roles.label" default="Roles"/>:</td>
            </tr>
            <%--
            <g:each in="${roles}" var="role">
            <tr>
              <td valign="top" class="name" align="left">${role.description.encodeAsHTML()}</td>
              <td align="left"><g:checkBox name="${role.code}"/></td>
            </tr>
            </g:each>
              --%>
            <g:each in="${roles}" var="role">
            <tr>
              <td valign="top" class="name" align="left">${role.description.encodeAsHTML()}</td>
              <g:set var="isDisabled" value="" />
              <g:set var="isChecked" value="false" />
              <g:if test="${role.code == 'ROLE_USER'}">
                <g:set var="isChecked" value="true" />
                <g:set var="isDisabled" value="true" />
              </g:if>
              <td align="left"><g:checkBox name="${role.code}" value="${role.code}" checked="${isChecked}" disabled="${isDisabled}"/></td>
            </tr>
            </g:each>
          
          </tbody>
          </table>
        </fieldset>
        </div>
        <div class="buttons">
          <span class="button"><input class="save" type="submit" value="${message(code:'global.create')}"/></span>
        </div>
      </g:form>
    </div>
  </body>
</html>